package com.ltv.xiangqiplugin.models;

import java.util.Vector;

public class BoardSize {
	private BoardSizeEnum size;
	private Vector<BoardSizeObserver> observers;
	
	public BoardSize() {
		size = BoardSizeEnum.MEDIUM;
		observers = new Vector<BoardSizeObserver>();
	}
	
	public void setSize(BoardSizeEnum size) {
		if (this.size != size) {
			this.size = size;
			notifyObservers(size);
		}
	}

	public void addObserver(BoardSizeObserver observer) {
		observers.add(observer);
	}
	
	public void removeObserver(BoardSizeObserver observer) {
		observers.remove(observer);
	}
	
	public void notifyObservers(BoardSizeEnum size) {
		for (BoardSizeObserver observer : observers) {
			observer.boardSizeChanged(size);
		}
	}
}
